from .basedata import *

class UrlsListPanelGUI(wx.Panel, BaseData):

    def __init__(self, parent = None):
        BaseData.__init__(self)
        wx.Panel.__init__(self, parent, wx.ID_ANY)
        
        self._init_UI()  # 初始化界面布局
        self._init_Ref()
        
    def _init_UI(self):
        """初始化UI界面"""
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        self.SetBackgroundColour(CON_COLOR_MAIN)

        self.panel = wx.Panel(self, wx.ID_ANY)
        topsizer = wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(topsizer)
        topsizer.SetSizeHints(self.panel)
        sizer.Add(self.panel, 1, wx.EXPAND)

        '''
            操作工具栏
        '''
        self.toolsPanel = wx.Panel(self.panel)
        toolsPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.toolsPanel.SetSizer(toolsPanelSizer)
        topsizer.Add(self.toolsPanel, 0, wx.EXPAND | wx.ALL, 0)

        '''
            搜索引擎的依据
        '''
        self.choiceSearch = wx.Choice(self.toolsPanel, -1, choices=[
            "选择搜索依据",
            BasisAnalysisObj.BASIS_RELATE_PATH.value,
            BasisAnalysisObj.BASIS_WHOLE_PATH.value,
            BasisAnalysisObj.BASIS_BELONG_APP.value,
            BasisAnalysisObj.BASIS_APP_NAME.value,
            BasisAnalysisObj.BASIS_URL_ALIAS.value,
            BasisAnalysisObj.BASIS_ANALYSIS_NAME.value,
        ])
        toolsPanelSizer.Add(self.choiceSearch, 0, wx.EXPAND | wx.ALL, 0)
        self.choiceSearch.SetSelection(0)
        self.choiceSearch.SetBackgroundColour(CON_COLOR_MAIN)
        self.choiceSearch.SetForegroundColour(CON_COLOR_PURE_WHITE)

        self.searcher = wx.SearchCtrl(self.toolsPanel, style=wx.TE_PROCESS_ENTER)
        self.searcher.ShowSearchButton(True)
        self.searcher.ShowCancelButton(True)
        toolsPanelSizer.Add(self.searcher, 1, wx.EXPAND | wx.ALL, 0)

        self.btn_refresh = buttons.GenButton(self.toolsPanel, -1, label='重置/刷新')
        toolsPanelSizer.Add(self.btn_refresh, 0, wx.EXPAND | wx.ALL, 0)
        self.btn_refresh.SetBackgroundColour(CON_COLOR_MAIN)
        self.btn_refresh.SetForegroundColour(CON_COLOR_PURE_WHITE)

        '''
            树形列表
        '''
        self.treeListData = wxdv.DataViewCtrl(self.panel,
            style = wx.BORDER_THEME
            | wxdv.DV_ROW_LINES # 斑马纹
            | wxdv.DV_HORIZ_RULES
            | wxdv.DV_VERT_RULES
            | wxdv.DV_VARIABLE_LINE_HEIGHT
            # | wxdv.DV_MULTIPLE # 多选
            | wxdv.DV_SINGLE # 单选
        )
        topsizer.Add(self.treeListData, 1, wx.EXPAND | wx.ALL, 0)

    def _init_Ref(self):
        '''初始化右击菜单项'''
        self.popup_open_url = wx.NewIdRef()
        self.popup_open_view_path = wx.NewIdRef()
        self.popup_open_url_path = wx.NewIdRef()
        self.popup_open_template_path = wx.NewIdRef()
        self.popup_modify_url = wx.NewIdRef()
        self.popup_insert_func = wx.NewIdRef()
        self.popup_get_code = wx.NewIdRef()
        self.popup_show_mvc_mtv = wx.NewIdRef()
        self.popup_open_model_path = wx.NewIdRef()
